home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / misc / egs.lha / EGS / EGS_Devels / Examples / Other / curvestar.c < prev    next >
C/C++ Source or Header  |  1993-02-17  |  3KB  |  112 lines

  1. /* curvestar.c
  2.  *
  3.  * FM - 12.08.92
  4.  *
  5.  * Renders a colour flow in the shape of a star by using B-Splines
  6.  *
  7.  */
  8. #include <exec/types.h>
  9. #include <proto/exec.h>
  10. #include <egs/egsintui.h>
  11. #include <egs/proto/egsintui.h>
  12. #include <egs/pragmas/egsintui.h>
  13. #include <egs/egsgfx.h>
  14. #include <egs/proto/egsgfx.h>
  15. #include <egs/pragmas/egsgfx.h>
  16. #include <egs/egs.h>
  17. #include <egs/proto/egs.h>
  18. #include <egs/pragmas/egs.h>
  19. #include <egs/egsblit.h>
  20.  
  21. /* the pointers to our libraries */
  22. struct Library *EGSIntuiBase;
  23. struct Library *EGSGfxBase;
  24. struct Library *EGSBase;
  25.  
  26.  
  27. /* Rendering of a regular round star with four spikes */
  28. void drawStar8( EG_RastPortPtr rp, long mx, long my, long h1, long h2 )
  29. {
  30.         EG_AreaMove ( rp, mx, my-h1 );
  31.         EG_AreaCurve( rp, h2, h1-h2, h2-h1, -h2, mx+h1, my   );
  32.         EG_AreaCurve( rp, h2-h1, h2, h2, h2-h1, mx,    my+h1 );
  33.         EG_AreaCurve( rp, -h2, h2-h1, h1-h2, h2, mx-h1, my   );
  34.         EG_AreaCurve( rp, h1-h2, -h2, -h2, h1-h2, mx, my-h1 );
  35.         EG_AreaEnd( rp );
  36. }
  37.  
  38.  
  39. /* something's happening here */
  40. #define MAX_SIZE        100
  41.  
  42. void doThings( EI_WindowPtr window )
  43. {
  44.         long size;
  45.         struct EB_ClipRect clip;
  46.  
  47.         clip.Next   = NULL;
  48.         clip.Left   = window->BorderLeft;
  49.         clip.Top    = window->BorderTop;
  50.         clip.Right  = window->BorderLeft+window->Width-1;
  51.         clip.Bottom = window->BorderTop+window->Height-1;
  52.  
  53.         EG_InstallClipRegion(window->RPort,&clip);
  54.  
  55.         for( size=2*MAX_SIZE; size>1; size-- )
  56.                 {
  57.                 EG_SetAPen( window->RPort, ((255*size)/MAX_SIZE)*0x1010000 + 0x0000ff00 );
  58.                 drawStar8( window->RPort, window->Width/2 + window->BorderLeft,
  59.                                           window->Height/2 + window->BorderTop ,
  60.                                           MAX_SIZE,size );
  61.                 }
  62.  
  63.         EG_RemoveClipRegion(window->RPort);
  64.  
  65.         WaitPort( window->UserPort );
  66. }
  67.  
  68.  
  69. /* main program */
  70. void main( int argc, char *argv[] )
  71. {
  72.         static struct EI_NewWindow newWindow =
  73.                 {
  74.                 50,30, 400,300,
  75.                 0,0, 0,0,
  76.                 NULL,
  77.                 EI_WINDOWCLOSE | EI_WINDOWBACK | EI_WINDOWDRAG,
  78.                 NULL,
  79.                 "Testfenster",
  80.                 EI_SMART_REFRESH,
  81.                 EI_iCLOSEWINDOW,
  82.                 NULL,
  83.                 {0,0,0,0,0,0,0},
  84.                 NULL,
  85.                 NULL
  86.                 };
  87.     EI_WindowPtr window;
  88.  
  89.         /* die Libraries öffnen */
  90.         EGSIntuiBase = OpenLibrary( (UBYTE *)"egsintui.library", 0 );
  91.         if ( EGSIntuiBase )
  92.                 {
  93.                 EGSGfxBase = OpenLibrary( (UBYTE *)"egsgfx.library", 0 );
  94.                 if ( EGSGfxBase )
  95.                         {
  96.                         EGSBase = OpenLibrary( (UBYTE *)"egs.library", 0 );
  97.                         if ( EGSBase )
  98.                                 {
  99.                         window = EI_OpenWindow( &newWindow );
  100.                     if ( window )
  101.                                 {
  102.                                 doThings( window );
  103.                                 EI_CloseWindow( window );
  104.                                 }
  105.                                 CloseLibrary( EGSBase );
  106.                                 }
  107.                 CloseLibrary( EGSGfxBase );
  108.                 }
  109.                 CloseLibrary( EGSIntuiBase );
  110.                 }
  111. }
  112.